package com.app.brilliant.system.service.impl;
import com.app.brilliant.common.service.impl.BaseServiceImpl;
import com.app.brilliant.system.scheduled.bean.ScheduleJobLogExample;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.app.brilliant.system.entity.ScheduleJobLog;
import com.app.brilliant.system.mapper.ScheduleJobLogMapper;
import com.app.brilliant.system.service.ScheduleJobLogService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
@Slf4j
@Service
public class ScheduleJobLogServiceImpl extends BaseServiceImpl<ScheduleJobLogMapper, ScheduleJobLog> implements ScheduleJobLogService {
    @Autowired
    private ScheduleJobLogMapper scheduleJobLogMapper;
    @Override
    public PageInfo queryPage(Map<String, Object> params) {
        Long jobId = Long.parseLong(params.get("jobId").toString());
        Integer page = Integer.parseInt(params.get("page").toString());
        Integer pageSize = Integer.parseInt(params.get("pageSize").toString());

        PageHelper.startPage(page,pageSize);
        ScheduleJobLogExample scheduleJobLogExample = new ScheduleJobLogExample();
        scheduleJobLogExample.createCriteria().andJobIdEqualTo(jobId);
        List<ScheduleJobLog> scheduleJobLogs = scheduleJobLogMapper.selectByExample(scheduleJobLogExample);
        PageInfo pageInfo = new PageInfo<>(scheduleJobLogs);
        return pageInfo;
    }

}
